import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class ClientHandler implements Runnable{
	
	private ServerSocket server;
	private DataBaseSaver saver;
	
	public ClientHandler(ServerSocket server){
		this.server = server;	
		this.saver = new DataBaseSaver();		
	}

	@Override
	public void run() {
		try{
			while(true){
				Socket client = server.accept();
				
				//XML bestand parsen en daarbij de gegevens in het object "Data" plaatsen
				XMLparser parser = new XMLparser(client.getInputStream());
				
				//Client sluiten
				client.close();	
				
				//Measurements opslaan				
				saver.save(parser.getData());
				
			}
		}catch(IOException ioe){
			ioe.printStackTrace();
		}
		
	}
}